package com.ktgj.flight.controller;

import java.util.List;
import java.io.IOException;
import java.util.Map;
import javax.servlet.http.HttpServletResponse;

import com.alibaba.fastjson.JSON;
import com.ktgj.common.spring.entity.iata.iata_airshoppingrq.AircraftType;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import com.ktgj.common.log.annotation.Log;
import com.ktgj.common.log.enums.BusinessType;
import com.ktgj.common.security.annotation.PreAuthorize;
import com.ktgj.flight.domain.FlightAiraccount;
import com.ktgj.flight.service.IFlightAiraccountService;
import com.ktgj.common.core.web.controller.BaseController;
import com.ktgj.common.core.web.domain.AjaxResult;
import com.ktgj.common.core.utils.poi.ExcelUtil;
import com.ktgj.common.core.web.page.TableDataInfo;

/**
 * 航司B2B账号Controller
 * 
 * @author ruoyi
 * @date 2021-11-12
 */
@ControllerAdvice
@RestController
@RequestMapping("/airaccount")
public class FlightAiraccountController extends BaseController
{
    @Autowired
    private IFlightAiraccountService flightAiraccountService;

    /**
     * 查询航司B2B账号列表
     */
    //@PreAuthorize(hasPermi = "flight:airaccount:list")
    @PostMapping("/list")
    public TableDataInfo list(@RequestBody FlightAiraccount flightAiraccount)
    {
        startPage();
        List<FlightAiraccount> list = flightAiraccountService.selectFlightAiraccountList(flightAiraccount);
        return getDataTable(list);
    }

    /**
     * 导出航司B2B账号列表
     */
    @PreAuthorize(hasPermi = "flight:airaccount:export")
    @Log(title = "航司B2B账号", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, FlightAiraccount flightAiraccount) throws IOException
    {
        List<FlightAiraccount> list = flightAiraccountService.selectFlightAiraccountList(flightAiraccount);
        ExcelUtil<FlightAiraccount> util = new ExcelUtil<FlightAiraccount>(FlightAiraccount.class);
        util.exportExcel(response, list, "航司B2B账号数据");
    }

    /**
     * 获取航司B2B账号详细信息
     */
//    @PreAuthorize(hasPermi = "flight:airaccount:query")
//    @GetMapping(value = "/{accountId}")
    @PostMapping("/getInfo")
    public AjaxResult getInfo(@RequestBody Map<String,Object> map)
    {
        Long accountId = Long.valueOf(map.get("accountId").toString());
        return AjaxResult.success(flightAiraccountService.selectFlightAiraccountById(accountId));
    }

    /**
     * 新增航司B2B账号
     */
//    @PreAuthorize(hasPermi = "flight:airaccount:add")
//    @Log(title = "航司B2B账号", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    public AjaxResult add(@RequestBody FlightAiraccount flightAiraccount)
    {
        return toAjax(flightAiraccountService.insertFlightAiraccount(flightAiraccount));
    }

    /**
     * 修改航司B2B账号
     */
//    @PreAuthorize(hasPermi = "flight:airaccount:edit")
//    @Log(title = "航司B2B账号", businessType = BusinessType.UPDATE)
    @PostMapping("/update")
    public AjaxResult update(@RequestBody FlightAiraccount flightAiraccount)
    {
        return toAjax(flightAiraccountService.updateFlightAiraccount(flightAiraccount));
    }

    /**
     * 删除航司B2B账号
     */
//    @PreAuthorize(hasPermi = "flight:airaccount:remove")
//    @Log(title = "航司B2B账号", businessType = BusinessType.DELETE)
//	@DeleteMapping("/{accountIds}")
    @PostMapping("/delete")
    public AjaxResult remove(@RequestBody Map<String,Object> map)
    {
        Long accountId = Long.valueOf(map.get("accountId").toString());
        return toAjax(flightAiraccountService.deleteFlightAiraccountById(accountId));
    }
    
}
